package com.guigu.eduservice.controller;

import com.guigu.common.utils.R;
import com.guigu.eduservice.entity.EquipmentType;
import com.guigu.eduservice.service.EquipmentTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/eduservice/equipmentType")
public class EquipmentTypeController {
    @Autowired
    private EquipmentTypeService equipmentTypeService;
    @GetMapping("/getById/{id}")
    public EquipmentType getById(@PathVariable("id") Long id) {
        return equipmentTypeService.getById(id);
    }

    @GetMapping("/getAll")
    public List<EquipmentType> getAll() {
        return equipmentTypeService.list(null);
    }

    // 获取树形结构的设备类型
    @GetMapping("/getTypeTree")
    public R getTypeTree() {
        List<EquipmentType> typeTree = equipmentTypeService.getTypeTree();
        return R.ok().data("typeTree", typeTree);
    }
}
